package com.g8.pethospitallearnbackend.mapper;

import com.g8.pethospitallearnbackend.entity.Paper;
import com.g8.pethospitallearnbackend.entity.PaperExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface PaperMapper {
    @SelectProvider(type=PaperSqlProvider.class, method="countByExample")
    long countByExample(PaperExample example);

    @DeleteProvider(type=PaperSqlProvider.class, method="deleteByExample")
    int deleteByExample(PaperExample example);

    @Delete({
        "delete from paper",
        "where paper_id = #{paperId,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String paperId);

    @Insert({
        "insert into paper (paper_id, paper_name, ",
        "paper_score)",
        "values (#{paperId,jdbcType=VARCHAR}, #{paperName,jdbcType=VARCHAR}, ",
        "#{paperScore,jdbcType=INTEGER})"
    })
    int insert(Paper record);

    @InsertProvider(type=PaperSqlProvider.class, method="insertSelective")
    int insertSelective(Paper record);

    @SelectProvider(type=PaperSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="paper_id", property="paperId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="paper_name", property="paperName", jdbcType=JdbcType.VARCHAR),
        @Result(column="paper_score", property="paperScore", jdbcType=JdbcType.INTEGER)
    })
    List<Paper> selectByExample(PaperExample example);

    @Select({
        "select",
        "paper_id, paper_name, paper_score",
        "from paper",
        "where paper_id = #{paperId,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="paper_id", property="paperId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="paper_name", property="paperName", jdbcType=JdbcType.VARCHAR),
        @Result(column="paper_score", property="paperScore", jdbcType=JdbcType.INTEGER)
    })
    Paper selectByPrimaryKey(String paperId);

    @UpdateProvider(type=PaperSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Paper record, @Param("example") PaperExample example);

    @UpdateProvider(type=PaperSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Paper record, @Param("example") PaperExample example);

    @UpdateProvider(type=PaperSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Paper record);

    @Update({
        "update paper",
        "set paper_name = #{paperName,jdbcType=VARCHAR},",
          "paper_score = #{paperScore,jdbcType=INTEGER}",
        "where paper_id = #{paperId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Paper record);
}